package s_001_Bean_Registered;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import s_001_Bean_Registered.bean.Person;

public class MainXmlTest {
    public static void main(String[] args) {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("s_001_Bean_Registered.xml");
        Person bean = (Person) applicationContext.getBean("person");
        System.out.println(bean);

        // 打印 IOC 容器中所有 Person 类型的 bean 的名称
        String[] namesForType = applicationContext.getBeanNamesForType(Person.class);
        for (String name : namesForType) {
            System.out.println(name);
        }
    }
}